package com.leetcode.week.week293;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author angzhijin
 * @Description
 * @create 2022-05-15 10:32 上午
 */
public class Week1 {
    public static void main(String[] args) {

    }

    public static List<String> removeAnagrams(String[] words) {
        List<String> res = new ArrayList<>();
        res.add(words[0]);
        if(words.length<2) return res;
        char[] prev = res.get(res.size()-1).toCharArray();
        Arrays.sort(prev);
        for (int i = 1; i < words.length; i++) {
            char[] current = words[i].toCharArray();
            Arrays.sort(current);
            if(!String.valueOf(prev).equals(String.valueOf(current))){
                res.add(words[i]);
                prev=current;
            }
        }
        return res;
    }
}
